| Total Complexity | 1 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | import DataStorage from '@enbock/simple-storage/DataStorage'; |
||
| 6 | |||
| 7 | class Container { |
||
| 8 | registry: ThemesRegistry; |
||
| 9 | currentThemeAdapter: ListenerAdapter<Theme>; |
||
| 10 | currentTheme: ValueObserver<Theme>; |
||
| 11 | manager: ThemesManager; |
||
| 12 | storage: DataStorage; |
||
| 13 | |||
| 14 | constructor() { |
||
| 15 | 2 | this.storage = new DataStorage('theme', window.localStorage); |
|
| 16 | 2 | this.registry = new ThemesRegistry(); |
|
| 17 | 2 | this.currentThemeAdapter = new ListenerAdapter<Theme>(); |
|
| 18 | 2 | this.currentTheme = new ValueObserver<Theme>( |
|
| 19 | this.storage.loadData<Theme>( |
||
| 20 | 'currentTheme', |
||
| 21 | { |
||
| 22 | isBuildIn: true, |
||
| 23 | name: 'Google', |
||
| 24 | url: 'Theme/Google' |
||
| 25 | } |
||
| 26 | ), |
||
| 27 | this.storage.attach<Theme>('currentTheme', this.currentThemeAdapter) |
||
| 28 | ); |
||
| 29 | 2 | this.manager = new ThemesManager(this.currentTheme, this.registry); |
|
| 30 | |||
| 31 | 2 | this.setupDefaults(); |
|
| 32 | } |
||
| 33 | |||
| 34 | protected setupDefaults(): void { |
||
| 35 | 2 | this.registry.registerTheme({ |
|
| 36 | isBuildIn: true, |
||
| 37 | name: 'Google', |
||
| 38 | url: 'Theme/Google' |
||
| 39 | }); |
||
| 40 | 2 | this.registry.registerTheme({ |
|
| 41 | isBuildIn: true, |
||
| 42 | name: 'Codefrog', |
||
| 43 | url: 'Theme/Codefrog' |
||
| 44 | }); |
||
| 49 |